package com.ukao.cashregister.adapter;

import android.content.Context;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.VipGroupBean;

import java.util.List;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class VipGroupListAdapter extends CommonAdapter<VipGroupBean> {


    private boolean isGroupEnter;

    public VipGroupListAdapter(Context context, List<VipGroupBean> datas, boolean isGroupEnter) {
        super(context, datas, R.layout.adapter_vip_grouplist);
        this.isGroupEnter = isGroupEnter;

    }

    public VipGroupListAdapter(Context context, List<VipGroupBean> datas) {
        super(context, datas, R.layout.choose_time_item);
    }


    @Override
    public void convert(ViewHolder viewHolder, VipGroupBean item) {

        if (isGroupEnter) {
            ((TextView) viewHolder.getView(R.id.name)).setText(item.getName());
//            if ( item.getCnt()==0){
//
//            }else{
//                ((TextView) viewHolder.getView(R.id.name)).setText(item.getName()+" ("+item.getCnt()+")");
//            }

            if (item.isCheck()) {
                viewHolder.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.line));

            } else {
                viewHolder.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.white));

            }

        } else {
            TextView tagTxt = viewHolder.getView(R.id.tag_txt);
            tagTxt.setText(item.getName());
            if (item.isCheck()) {
                tagTxt.setBackgroundResource(R.drawable.add_list_item_checked);
                tagTxt.setTextColor(mContext.getResources().getColor(R.color.white));
            } else {
                tagTxt.setBackgroundResource(R.drawable.add_list_item);
                tagTxt.setTextColor(mContext.getResources().getColor(R.color.black));
            }

        }

    }


}
